package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.EncryptUtils;
import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.AbstractBlockService;
import com.medicine.manage.block.service.IBlockProcessService;
import com.medicine.manage.block.service.IBlockService;

import com.medicine.manage.domain.Soaking;
import org.springframework.stereotype.Service;

@Service("blockProcessSoakingService")
public class BlockProcessSoakingServiceImpl extends AbstractBlockService<Soaking> implements IBlockProcessService<Soaking> {

    private final String INSERT_ONE_METHOD = "insertSoaking";
    private final String SELECT_ONE_METHOD = "selectSoaking";
    private final String UPDATE_METHOD = "updateSoaking";

    @Override
    public WeBaseResult insertProcessObj(Soaking soaking, Long deptId, Long optionUserId) {
        return this.insertOne(soaking, deptId, optionUserId, INSERT_ONE_METHOD);
    }

    @Override
    public WeBaseResult selectProcessObj(Long orderId, Long soakingId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, soakingId, deptId, optionUserId, SELECT_ONE_METHOD);
    }

    @Override
    public WeBaseResult updateProcessObj(Soaking soaking, Long deptId, Long optionUserId) {
        return this.update(soaking.getOrderId(), soaking, deptId, optionUserId, UPDATE_METHOD);
    }

    @Override
    protected String createParam(Soaking o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)
                .append(o.getContainerId()).append(IBlockService.SEPARATOR)
                .append(o.getCurrentScanInfo()).append(IBlockService.SEPARATOR)
                .append(o.getImage()==null || o.getImage().isEmpty() ? "": EncryptUtils.sha256(o.getImage())).append(IBlockService.SEPARATOR)
                .append(optionUserId);

        return param.toString();
    }

}
